package com.university.mentalhealthplatform.studentV3.controller;

import com.university.mentalhealthplatform.appModels.Tweet;
import com.university.mentalhealthplatform.studentV3.service.TweetServiceV3;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/v3/precaution")
public class TweetControllerV3 {

    @Autowired
    private TweetServiceV3 tweetServiceV3;

    @GetMapping("/tweets")
    public ResponseEntity<List<Tweet>> getAllTweets() {
        List<Tweet> tweets = tweetServiceV3.getAllTweets();
        return ResponseEntity.ok(tweets);
    }
    @GetMapping("/tweetDetail/{id}")
    public ResponseEntity<Tweet> getTweetById(@PathVariable Long id) {
        Tweet tweet = tweetServiceV3.getTweetById(id);
        if (tweet != null) {
            return ResponseEntity.ok(tweet);
        } else {
            return ResponseEntity.notFound().build();
        }
    }
}
